package operation.impl;

import book.Book;
import book.BookList;
import operation.IOperation;

/**
 * 更新书籍
 */
public class UpdataOperation implements IOperation {
    @Override
    public void work(BookList bookList) {
        System.out.println("当前进行的是更新书籍操作~");
        System.out.print("请输入书籍名称：");
        String bookName= scanner.next();
        if(bookList.contains(bookName)){
            Book book=bookList.currentBook(bookName);
            System.out.println("===============================");
            System.out.println("        1.修改书籍作者");
            System.out.println("        2.修改书籍价格");
            System.out.println("        3.修改书籍类型");
            System.out.println("===============================");
            System.out.println("请输入您的选项：");
            int choice=scanner.nextInt();
            switch(choice){
                case 1:
                    System.out.print("请输入修改后的书籍作者：");
                    String author = scanner.next();
                    book.setAuthor(author);
                    System.out.println("更新书籍成功！");
                    break;
                case 2:
                    System.out.print("请输入修改后的书籍价格：");
                    double prize = scanner.nextDouble();
                    book.setPrize(prize);
                    System.out.println("更新书籍成功！");
                    break;
                case 3:
                    System.out.print("请输入修改后的书籍类型：");
                    String type = scanner.next();
                    book.setType(type);
                    System.out.println("更新书籍成功！");
                    break;
                default:
                    System.out.println("输入有误！");
                    break;
            }
        }else {
            System.out.println("无该书籍~");
            return;
        }

    }
}
